//
//  AtomFeedEntry+LinkableItem.swift
//  RssFly
//
//  Created by shen on 2023/10/17.
//

import Foundation
import FeedKit

extension AtomFeedEntry: LinkableItem {
    var linkURL: URL? {
        guard let linkString = links?.first(where: { atomLink in
            atomLink.attributes?.rel == "alternate" || atomLink.attributes?.rel == nil
        })?.attributes?.href?.trimmingCharacters(in: .whitespacesAndNewlines),
            let linkURL = URL(string: linkString)
        else {
            return nil
        }

        return linkURL
    }
}
